﻿
Namespace LightSwitchApplication

    Public Class Media

        Private Sub FileSize_Compute(ByRef result As String)
            ' Set result to the desired field value
            Dim kb = CType(Me.File.Length, Double) / 1024

            If kb < 1 And kb <> 0 Then
                kb = 1
            End If
            result = String.Format("{0:#,0} KB", kb)
        End Sub

        Private Sub FileForDisplay_Compute(ByRef result As Byte())
            ' Set result to the desired field value
            If Not Me.FileXps Is Nothing Then
                ' there is an XPS conversion result, display it
                result = Me.FileXps
            Else
                ' otherwise display the original file
                result = Me.File
            End If
        End Sub
    End Class

End Namespace
